﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1.Chat
{
    public partial class WebForm2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserName"]==null || Request.Cookies["Pwd"]== null)
            {
                Response.Redirect("WebForm1.aspx");
            }
            if (Application["Chat"]==null)
            {
                Application["Chat"] = new Panel();
            }
            Panel1.Controls.Add((Panel)Application["Chat"]);
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string name = Session["UserName"].ToString();
            string time = DateTime.Now.ToString();
            string text = TextBox1.Text;

            Literal literal = new Literal();
            literal.Text = name + " " + time + ":" + text + "<br/>";
            ((Panel)Application["Chat"]).Controls.Add(literal);
        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            Session.Abandon();
            Response.Redirect("WebForma.aspx");
        }
    }
}